#pragma once

#ifndef APPLICATION_H_
#define APPLICATION_H_

#include <iostream>
#include "IPresentation.h"
#include "IBusiness.h"
#include "IEventsHandler.h"

namespace coder
{

class Application : public IEventsHandler
{
private:
	IPresentation & _presentation;
	IBusiness & _business;
	
public:
	Application(IPresentation & presentation, IBusiness & business) 
		:_presentation(presentation), _business(business)
	{
		_presentation.setText(_business.getText());
		_presentation.setTitle(_business.getFileName());
		_presentation.setEventsHandler(this);
	}
	
	void run() 
	{
		_presentation.show();
	}

	virtual void handle(const ApplicationEvent & event)
	{
		if(event.id == "save")
		{
			_business.setText(_presentation.getText());
		}
	}
};

}

#endif /*APPLICATION_H_*/
